s = input()
sk = ""
skobka = ""
flag = True
for skobka in s:
    if skobka in "({[<":
        sk = sk + skobka
    if sk == "":
        flag = False
        break
    elif skobka in ")]}>":
        last = sk[-1]
        if skobka == ")" and last == "(":
            sk = sk[:-1]
        if skobka == "]" and last == "[":
            sk = sk[:-1]
        if skobka == "}" and last == "{":
            sk = sk[:-1]
        if skobka == ">" and last == "<":
            sk = sk[:-1]
if flag == False:
    print(False)
elif sk == "":
    print(True)
else:
    print(False)
